package logic

import (
	"context"
	"video-management-system/userrpc/userrpc"

	"video-management-system/api/internal/svc"
	"video-management-system/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateVideoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUpdateVideoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateVideoLogic {
	return &UpdateVideoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UpdateVideoLogic) UpdateVideo(req *types.UpdateVideoRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	video, err := l.svcCtx.UserRpc.UpdateVideo(l.ctx, &userrpc.UpdateVideoRequest{
		Uid:         req.Uid,
		Vid:         req.Vid,
		VideoStatus: req.VideoStatus,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}
	return &types.Response{
		Message: "操作成功",
		Data:    video,
		Code:    200,
	}, nil
}
